<template>
  <div class="grid-content">
    <div class="code" @click="refreshCode">
      <s-identify :identifyCode="identifyCode"></s-identify>
    </div>
    <el-input placeholder="请输入6位数字验证码" v-model="vcode" @keyup.enter.native="submitForm()" ref="lgvcode"
      style="width:150px;">
    </el-input>
  </div>
</template>

<script>
import SIdentify from "./identify";
export default {
  name: "",
  components: {
    SIdentify,
  },
  data() {
    return {
      vcode: "",
      identifyCodes: "1234567890",
      identifyCode: "",
    };
  },
  created() { },
  mounted() {
    this.refreshCode();
  },
  methods: {
    randomNum(min, max) {
      return Math.floor(Math.random() * (max - min) + min);
    },
    refreshCode() {
      this.identifyCode = "";
      this.makeCode(this.identifyCodes, 6);
    },
    makeCode(o, l) {
      for (let i = 0; i < l; i++) {
        this.identifyCode += this.identifyCodes[this.randomNum(0, this.identifyCodes.length)];
      }
      // console.log(this.identifyCode);
    },
    submitForm() {
      this.$parent.$parent.confirm();
    },
  },
  computed: {},
};
</script>
<style scoped>
.grid-content {
  text-align: center;
}
</style>
